/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ifrr.gepro.sprint.bean;

import br.ifrr.gepro.estoria.bean.EstoriasBean;
import br.ifrr.gepro.projeto.bean.ProjetoBean;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author rafael
 */
@Entity
@Table(name = "sprint", catalog = "gepro", schema = "public")
public class SprintBean implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id_sprint", nullable = false, insertable = false)
    private Integer idSprint;
    @Column(name = "nome", length = 45)
    private String nome;
    @Column(name = "data_in")
    @Temporal(TemporalType.DATE)
    private Date dataIn;
    @Column(name = "data_fim")
    @Temporal(TemporalType.DATE)
    private Date dataFim;
//    @OneToMany(mappedBy = "fkSprint")
//    private Collection<EstDoSprintBean> estDoSprintBeanCollection;
    @JoinColumn(name = "fk_proj", referencedColumnName = "id_projeto")
    @ManyToOne
    private ProjetoBean fkProj;
    
    @JoinTable(name = "est_do_sprint", joinColumns = {
        @JoinColumn(name = "fk_sprint", referencedColumnName = "id_sprint", nullable = false)}, inverseJoinColumns = {
        @JoinColumn(name = "fk_estoria", referencedColumnName = "id_est", nullable = false)})
    @ManyToMany
    private Collection<EstoriasBean> estoriaBeanCollection;


    public SprintBean() {
    }

    public SprintBean(Integer idSprint) {
        this.idSprint = idSprint;
    }

    public Integer getIdSprint() {
        return idSprint;
    }

    public void setIdSprint(Integer idSprint) {
        this.idSprint = idSprint;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public Date getDataIn() {
        return dataIn;
    }

    public void setDataIn(Date dataIn) {
        this.dataIn = dataIn;
    }

    public Date getDataFim() {
        return dataFim;
    }

    public void setDataFim(Date dataFim) {
        this.dataFim = dataFim;
    }
//
//    public Collection<EstDoSprintBean> getEstDoSprintBeanCollection() {
//        return estDoSprintBeanCollection;
//    }
//
//    public void setEstDoSprintBeanCollection(Collection<EstDoSprintBean> estDoSprintBeanCollection) {
//        this.estDoSprintBeanCollection = estDoSprintBeanCollection;
//    }

    public ProjetoBean getFkProj() {
        return fkProj;
    }

    public void setFkProj(ProjetoBean fkProj) {
        this.fkProj = fkProj;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idSprint != null ? idSprint.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SprintBean)) {
            return false;
        }
        SprintBean other = (SprintBean) object;
        if ((this.idSprint == null && other.idSprint != null) || (this.idSprint != null && !this.idSprint.equals(other.idSprint))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.ifrr.gepro.SprintBean[ idSprint=" + idSprint + " ]";
    }

    public Collection<EstoriasBean> getEstoriaBeanCollection() {
        return estoriaBeanCollection;
    }

    public void setEstoriaBeanCollection(Collection<EstoriasBean> estoriaBeanCollection) {
        this.estoriaBeanCollection = estoriaBeanCollection;
    }

   


}
